<!--
 * @Author: Jieeeny
 * @Date: 2023-05-11 18:00:49
 * @LastEditors: Jieeeny  
 * @LastEditTime: 2023-11-16 15:12:46
 * @Description: 控件配置
 * @FilePath: \vite-vue3-ts-pinia-vueuse\src\components\Config.vue
-->
<template>
  <div class="config">
    <div class="config-title">
      配置：<span v-if="form.activeEle?.name">{{
        elements.find((item) => item.type === form.activeEle?.type)?.name
      }}</span>
    </div>
    <el-form
      v-if="form.activeEle?.name"
      :model="form.activeEle"
      :label-width="110"
      label-position="left"
      class="element-form"
    >
      <el-form-item label="名称" name="name">
        <el-input v-model="form.activeEle.name"></el-input>
      </el-form-item>
      <el-form-item label="不可编辑" name="disabled">
        <el-switch v-model="form.activeEle.disabled" />
      </el-form-item>
      <el-form-item label="布局百分比" name="layout">
        <el-radio-group v-model="form.activeEle.layout">
          <el-radio-button label="25%">25</el-radio-button>
          <el-radio-button label="50%">50</el-radio-button>
          <el-radio-button label="75%">75</el-radio-button>
          <el-radio-button label="100%">100</el-radio-button>
        </el-radio-group>
      </el-form-item>

      <el-form-item
        v-if="form.activeEle.type === 'input'"
        label="占位提示"
        name="placeholder"
      >
        <el-input
          v-model="form.activeEle.placeholder"
          placeholder="输入提示信息"
        />
      </el-form-item>
    </el-form>
  </div>
</template>

<script lang="ts">
import { defineComponent, watchEffect } from 'vue';
import { useFormStore } from '@/store/form';
import { elements } from '@/utils/elements';
export default defineComponent({
  setup() {
    const form = useFormStore();
    watchEffect(() => {
      console.log(form.activeEle.layout, 'active-change');
    });

    return {
      elements,
      form,
    };
  },
});
</script>

<style scoped lang="less">
.config {
  flex: 3;
  padding: 10px 20px;
  // padding-right: 0;
  // border: 1px solid;
  background-color: #fff;
  &-title {
    margin-bottom: 20px;
  }
  .element-form {
    :deep .el-radio-group {
      width: 100%;
      .el-radio-button {
        width: 25%;
        .el-radio-button__original-radio,
        .el-radio-button__inner {
          width: 100%;
        }
      }
    }
    :deep .el-form-item__content {
      justify-content: end;
    }
  }
}
</style>
